﻿function Get-TSMNodeAuditOccupancy {    
    <#
        .SYNOPSIS
            Get TSM node audit occupancy
                    
        .DESCRIPTION
            The Get-TSMNodeAuditOccupancy returns node audit occupancy
            
        .PARAMETER Node
            The node to search

        .EXAMPLE
            Get-TSMNodeAuditOccupancy

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/01/2015

    #>
    [CmdletBinding()]
    Param(        
        [Parameter(Position=0)]
        $Node
    )   
    
    $whereProps = @()
    $whereProps += [PSCustomObject]@{ "Column" = "NODE_NAME";   "Operator" = "LIKE"; "Value" = $Node }

    $query = Format-TSMQuery -Table "AUDITOCC" -Where $whereProps -OrderBy "NODE_NAME"
    $result = Invoke-TSMCommand -Command $query
    
    $defaultDisplaySet = 'NODE_NAME','BACKUP_MB','ARCHIVE_MB','SPACEMG_MB','TOTAL_MB'
    $typeDefinitions = @{
                        "BACKUP_MB"        = [Int32]
                        "BACKUP_COPY_MB"   = [Int32]
                        "ARCHIVE_MB"       = [Int32]
                        "ARCHIVE_COPY_MB"  = [Int32]
                        "SPACEMG_MB"       = [Int32]
                        "SPACEMG_COPY_MB"  = [Int32]
                        "TOTAL_MB"         = [Int32]
                        "BACKUP_ACTIVE_MB" = [Int32]
                        }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet
}